#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int hammingWeight(int n) {
        int ret = 0;
        while (n)
        {
            n &= (n - 1);
            ++ret;
        }
        return ret;
    }
};